package hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import servlet.Update;

import java.io.IOException;

public class HbaseUtilU extends Update {
    public String Update(String row,String id,String name,String price,String time ,String status) throws IOException{

        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","192.168.116.11");
        Connection connection = ConnectionFactory.createConnection(conf);

        HTable table = new HTable(conf,"goodsmessage");


        //Key cf c value
        Put put1 = new Put(Bytes.toBytes(row));
        put1.add(Bytes.toBytes("a"),
                Bytes.toBytes("id"),
                Bytes.toBytes(id));

        put1.add(Bytes.toBytes("b"),
                Bytes.toBytes("name"),
                Bytes.toBytes(name));

        put1.add(Bytes.toBytes("c"),
                Bytes.toBytes("price"),
                Bytes.toBytes(price));

        put1.add(Bytes.toBytes("d"),
                Bytes.toBytes("time"),
                Bytes.toBytes(time));

        put1.add(Bytes.toBytes("e"),
                Bytes.toBytes("status"),
                Bytes.toBytes(status));
        table.put(put1);

        return  "修改订单信息成功";
    }
}
